import service from "@/api/index.js";

const goodsApi = {
    //添加
    insert(goods){
      return service.post("/goods",goods);
    },
    //删除
    delete(id){
        return service.delete(`/goods/${id}`);
    },
    //修改
    update(goods){
        return service.put("/goods",goods);
    },
    //根据id查询
    selectById(id){
        return service.get(`/goods/${id}`);
    },
    //分页搜索
    selectByPage(condition,pageNum,pageSize){
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/goods",{
            params:condition
        })
    },
    //分页搜索 - 注意：分类id既可以是父分类的id也可以是子分类的id
    selectByPage1(condition,pageNum,pageSize){
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/goods/search",{
            params:condition
        })
    },
    //修改状态
    updateStatus(goods){
        return service.put("/goods/status",goods)
    },
    //商品评价
    insertScore(score){
        return service.post("/goods/score",score)
    }
};

export default goodsApi;